<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <button @click="sendReq01">请求行请求</button>
        <button @click="sendReq02">请求头请求</button>
        <button @click="sendReq03">请求体请求</button>
        <button @click="sendReq04">混合请求</button>
    </div>

    <script src="../js/vue.js"></script>
    <script src="../js/axios.min.js"></script>

    <script>
        //创建Vue实例
        var vm = new Vue({
            el: '#app',
            data: {

            },
            methods: {
                sendReq04: function () {
                    axios({
                        method: 'post',
                        baseURL: 'http://localhost:8080/',
                        url: 'test/test04',
                        params: {
                            name: '张三',
                            age: 18
                        },
                        headers: {
                            token: '123456'
                        },
                        data: {
                            name: '李四',
                            age: 20,
                            sex:'男',
                            address: '北京',
                            email: '123@qq.com',
                            phone: '1234567890'
                        }
                    }).then(res => {
                        console.log(res);
                    }).catch(error => {
                        console.log(error);
                    })
                },
                sendReq03: function () {
                    axios({
                        method: "POST",
                        baseURL: 'http://localhost:8080/',
                        url: 'test/test03',
                        data: {
                            "name": "John Doe",
                            "age": 30,
                            "sex": "Male",
                            "address": "123 Street, City",
                            "email": "john.doe@example.com",
                            "phone": "123-456-7890"
                        }
                    }).then(res => {
                        console.log(res);
                    }).catch(error => {
                        console.log(error);
                    })
                },
                sendReq02: function () {
                    axios({
                        method: 'get',
                        baseURL: 'http://localhost:8080/',
                        url: 'test/test02',
                        headers: {
                            token: '123456'
                        }
                    }).then(res => {
                        console.log(res);
                    }).catch(error => {
                        console.log(error);
                    })
                },
                sendReq01: function () {
                    axios({
                        method:'get',
                        baseURL: 'http://localhost:8080/',
                        url: 'test/test01',
                        params: {
                            name: '张三',
                            age: 18
                        }
                    }).then(res => {
                        console.log(res);
                    }).catch(error => {
                        console.log(error);
                    })
                }
            }
        })
    </script>
</body>

</html>